<script type="text/javascript" src="{{$LAYOUT_HELPER_URL}}admin/js/ckeditor/ckeditor.js"></script> 
<script type="text/javascript" src="{{$LAYOUT_HELPER_URL}}admin/js/ckfinder/ckfinder.js"></script>  
<link href="{{$LAYOUT_HELPER_URL}}admin/js/jquery-ui/css/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="{{$LAYOUT_HELPER_URL}}admin/js/jquery-ui/js/jquery-ui.js"></script>
<script src="{{$LAYOUT_HELPER_URL}}admin/js/jquery.slug.js"></script>



    
<script type="text/javascript">
    //<![CDATA[
jQuery(document).ready(function (){
    //Datepicker
    jQuery( ".date" ).datepicker({
        showAnim        : 'slideDown',
        showButtonPanel : true,
        dateFormat      : '{{$datepickerFormat.js}}'
    });
    
});


function addInput()
{
	 var value = $("#a").val();
     
     jQuery.ajax({
         url: '{{$APP_BASE_URL}}product/admin/add-input',
       type: "POST",
       data: {'value':value},
         beforeSend: function( xhr ) {
         },
         success: function( data ) {
        //Do anything
            //alert(data);
             appendOptionLast(data,value);
         }
      });
}

 jQuery(document).ready(function (){

		        
    });



function appendOptionLast(num,value)
{
  var elOptNew = document.createElement('option');
  elOptNew.text =  value;
  elOptNew.value =  num;
  var elSel = document.getElementById('add');

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}

function removeOptionLast()
{
	var elSel = document.getElementById('selectX');
	  var i;
	  for (i = elSel.length - 2; i>=0; i--) {
	    if (elSel.options[i].selected) {
	      elSel.remove(i);
	    }
	  }
}

    
//]]>
</script>

            <div class="content-box"><!-- Start Content Box -->
                
                <div class="content-box-header">
                    
                    <h3>New Product</h3>
                    
                    <div class="clear"></div>
                    
                </div> <!-- End .content-box-header -->
                
                <div class="content-box-content">
                
                    <form action="" method="post">
                    
                    <!-- LANGUAGES -->
                    <div class="tab-content" id="tab{{$lang.lang_id}}">
                            
                            <!-- ERROR -->
                        {{if $errors|@count > 0}}
                        <div class="notification error png_bg">
                            <a href="#" class="close"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
                            <div>
                                {{if $errors.main}}
                                    Error: {{$errors.main}}
                                {{else}}
                                    Error: Please check following information again
                                {{/if}} 
                                                                       
                            </div>
                        </div>
                        {{/if}}
                            
                            
                            <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
       
      
                                <p>
                                    <label>Tên sản phẩm</label>
<!--                                    {{$product.title}}-->
                                    <input class="text-input small-input" type="text"  name="product[title]" value="{{$product.title}}" />
                                </p>
                                </br>
                               <p>
                                    <label>Nhà sản xuất</label>
                                    <input class="text-input small-input" type="text"  name="data[provider]" value="{{$product.provider}}" />
                                </p>
                                
                               <p>
                                    <label>Ngày nhập</label>
                                        <input class="text-input small-input date" type="text"  name="data[created_date]" value="{{$date}}" />
                                        <br /><small>Format: {{$datepickerFormat.display}}</small>
                                </p>
                                
                                <p>
                                    <label>Giá nhập</label>
                                    <input class="text-input small-input" type="text"  name="data[input_price]" value="" />
                                    <br /><small>ngàn đồng (VND)</small>
                                </p>
                                
                                <p>
                                    <label>Số lượng</label>
                                    <input class="text-input small-input" type="text"  name="data[soluong]" value="" />
                                    <br /><small>đơn vị</small>
                                </p>
                                
                              
                              
                                <p>
                                     <label>Đơn vị</label>
<!--                                    {{if $item.unit_id == $data.unit}}selected="selected"{{/if}}-->
                                    <select id="add" name="data[unit]" class="small-input">
                                   {{foreach from=$allUnits item=item}}
<!--                                        <option value="{{$item.unit_id}}" selected="selected" >{{$item.name}}</option>-->
                                        <option value="{{$item.unit_id}}" {{if $item.unit_id == $product.unit}}selected="selected"{{/if}}>{{$item.name}}</option>
                                    {{/foreach}}
                                    </select> 
                                    </p>
                                  
                                  <p>
                                     <label>Thêm đơn vị</label>
                                    <input id="a" class="text-input small-input" type="text"  name="add[unit]" value=""  />
                                    <input class="button" onclick="addInput();" type="button" value="Thêm" />
                                    <br/>
                                    <br/>
                                 </p>
                                    
                                                          
                                
                                
                                
                                <p>
                                <br/>
                                    <input class="button submit" type="button" value="Save" />
                                </p>
                                
                            </fieldset>
                            
                            <div class="clear"></div><!-- End .clear -->
                            
                    </div>
                                
                        
                    
                  </form>
                  
                </div> <!-- End .content-box-content -->
                
            </div> <!-- End .content-box -->
            
            
            <div class="clear"></div>

